package com.cjb.base.controller;

import com.cjb.base.dao.UserMapper;
import com.cjb.base.domain.Orginazation;
import com.cjb.base.service.OrginazationService;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/orginazation")
public class OrginazationController {

    @Autowired
    private OrginazationService orginazationService;

    @Resource
    private UserMapper userMapper;


    @GetMapping("/index")
    public ModelAndView getView(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/orginazation.html");
        return mv;
    }

    @GetMapping(value="/treeNode",name = "查询所有的信息，构建页面中的树形")
    @ResponseBody
    //动态的过滤字段
    @JsonIgnoreProperties(value = {"code","note"})
    public List<Orginazation> treeNode(){
       return orginazationService.treeData();
    }


    @GetMapping(value = "/getByPid",name = "通过父级的id值获取子节点")
    @ResponseBody
    public List<Orginazation>  getByPid(String pid){
       return orginazationService.getByPid(pid);
    }


@GetMapping("/getall")
@ResponseBody
 public List<Orginazation> getall(){
     return     userMapper.getAll();
 }



}
